Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1x 1x 1x 1x 1x 1x | import { NextResponse } from 'next/server'
import { prisma } from '@/lib/prisma'
import { checkAdminAuth } from '@/lib/auth-check'
type Params = { params: Promise<{ categoryName: string }> }
// DELETE /api/admin/category-images/[categoryName] - Delete category image (Admin only)
export async function DELETE(request: Request, { params }: Params) {
const authError = await checkAdminAuth()
Iif (authError) return authError
try {
const { categoryName } = await params
await prisma.categoryImage.delete({
where: { categoryName: decodeURIComponent(categoryName) },
})
return NextResponse.json({ success: true })
} catch (error) {
console.error('Error deleting category image:', error)
return NextResponse.json({ error: 'Failed to delete category image' }, { status: 500 })
}
}
|